
package edu.uoc.tdp.pac3.beans;

import java.util.Date;

/**
 * Classe que representa una incidencia
 * 
 * @author Eloi Rebollo i Francesc Cabrera
 * @version 1.0
 */
public class Incidencia implements java.io.Serializable{
    
    private Integer idRequest;
    private Integer idUser;
    private Integer idArea;
    private Date creationDate;
    private String description;
    private boolean solved;

    public Incidencia(Integer idRequest, Integer idUser, Integer idArea, Date creationDate, String description, boolean solved) {
        this.idRequest = idRequest;
        this.idUser = idUser;
        this.idArea = idArea;
        this.creationDate = creationDate;
        this.description = description;
        this.solved = solved;
    }

    public Incidencia(Integer idUser, Integer idArea, Date creationDate, String description) {
        this.idRequest = null;
        this.idUser = idUser;
        this.idArea = idArea;
        this.creationDate = creationDate;
        this.description = description;
        this.solved = false;
    }

    public Date getCreationDate() {
        return creationDate;
    }

    public void setCreationDate(Date creationDate) {
        this.creationDate = creationDate;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Integer getIdArea() {
        return idArea;
    }

    public void setIdArea(Integer idArea) {
        this.idArea = idArea;
    }

    public Integer getIdRequest() {
        return idRequest;
    }

    public void setIdRequest(Integer idRequest) {
        this.idRequest = idRequest;
    }

    public Integer getIdUser() {
        return idUser;
    }

    public void setIdUser(Integer idUser) {
        this.idUser = idUser;
    }

    public boolean isSolved() {
        return solved;
    }

    public void setSolved(boolean solved) {
        this.solved = solved;
    }
    
    public boolean equals(Object obj) {
        boolean igual = false;
        if (obj != null) {
            if (obj instanceof Incidencia) {
                igual = this.getIdRequest().equals(((Incidencia) obj).getIdRequest());
            }
        }
        return igual;
    }

    @Override
    public String toString() {
        StringBuffer cadena = new StringBuffer();
        
        cadena.append(isSolved() + "\t");
        cadena.append(getIdRequest().toString() + "\t");
        cadena.append(getIdUser().toString() + "\t");
        cadena.append(getIdArea() + "\t");
        cadena.append(getCreationDate().toString() + "\t");
        cadena.append(getDescription() + "\t");
        
        return cadena.toString();
    }     
}
